//============================================================================
// Name        : TomoRecon.cpp
// Author      : Phan Quoc Huy, Joshi Basanta
// Version     :
// Copyright   : free to use and modify
// Description :
// camera calibration for a single camera incorporated  B Joshi 2010-2-11
// camera calibration for all camera incorporated  B Joshi 2010-2-14
// Problem with LOS reading discovered  because of dealy in writing a file using perl
// Initialisation computation are converted to functions and is called
// untill specified by Number of Iteration
//============================================================================

#include <iostream>
#include <cmath>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <boost/multi_array.hpp>

#include "Common.hpp"
#include "Utilities.hpp"
#include "include/lu.h"
#include "DataStructures.hpp"
#include "HallCalibration.hpp"
#include "FunctionsListOld.hpp"
#include "MART.hpp"

using namespace std;
/*
 * @brief main function receives a configure file. The structure of the file is described as follow
 * (1) <number of views>
 * (2) <image's prefix, e.g image_ , img_>
 * (3) <input data file>
 * (4) <output data file (the voxel volume)>
 * (5) <X position of the windows>
 * (6) <Y position of the windows>
 * (7) <Width of the windows>
 * (8) <Height of the windows>
 * @param argv[1] configure file name
 */

int main(int argc, const char* argv[]) {
	string config_file;

	if (argc < 2)
		cout << "Wrong number of parameter" << endl;
	else {
		config_file = string(argv[1]);
	}

	MART* mart;

	if (LoadConfig(config_file.c_str(), mart)==0) {
		ShowConfig(mart);
	} else {
		cout << "An error occurred when loading configure file " << endl;
		return -1;
	}

	if (LoadData(mart)!=0) {
		cout << "An error occurred when loading data files " << endl;
		return -1;
	}
	cout << "Finished loading data... \n";

	if (LoadImage(mart)!=0) {
		cout << "An error occurred when loading image files " << endl;
		return -1;
	}

	cout << "Finished loading images...\n";
	cout << "Running MART reconstruction...\n";

	mart->FullRun();

	delete mart;
	return 0;
}
